package com.yunji.news.common;

import lombok.Getter;

/**
 * 响应状态码枚举
 *
 * @author yunji
 * @since 2024-11-23
 */
@Getter
public enum ResultCode {
    
    /**
     * 成功响应
     */
    SUCCESS(200, "操作成功"),
    CREATED(201, "创建成功"),
    
    /**
     * 客户端错误
     */
    BAD_REQUEST(400, "请求参数错误"),
    UNAUTHORIZED(401, "未授权访问"),
    FORBIDDEN(403, "权限不足"),
    NOT_FOUND(404, "资源不存在"),
    METHOD_NOT_ALLOWED(405, "请求方法不允许"),
    VALIDATION_ERROR(422, "数据验证失败"),
    
    /**
     * 服务端错误
     */
    INTERNAL_SERVER_ERROR(500, "服务器内部错误"),
    BAD_GATEWAY(502, "网关错误"),
    SERVICE_UNAVAILABLE(503, "服务暂时不可用"),
    
    /**
     * 业务错误码
     */
    USER_NOT_FOUND(1001, "用户不存在"),
    USER_PASSWORD_ERROR(1002, "用户名或密码错误"),
    USER_ACCOUNT_DISABLED(1003, "账号已被禁用"),
    TOKEN_INVALID(1004, "Token无效"),
    TOKEN_EXPIRED(1005, "Token已过期"),
    
    SCHOOL_NOT_FOUND(2001, "院校不存在"),
    SCHOOL_CODE_EXISTS(2002, "院校代码已存在"),
    
    ARTICLE_NOT_FOUND(3001, "文章不存在"),
    CATEGORY_NOT_FOUND(3002, "分类不存在"),
    CATEGORY_HAS_ARTICLES(3003, "分类下存在文章，无法删除"),
    
    FILE_UPLOAD_ERROR(4001, "文件上传失败"),
    FILE_TYPE_NOT_SUPPORTED(4002, "文件类型不支持"),
    FILE_SIZE_EXCEEDED(4003, "文件大小超出限制");
    
    private final Integer code;
    private final String message;
    
    ResultCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }
}